import { View, Text, TouchableOpacity } from 'react-native';
import React from 'react';
import PropTypes from 'prop-types';
import { Modal, WhiteSpace } from '@ant-design/react-native';
import moment from 'moment';
import styles from './styles';
import { moveToRecycle } from '../../../../comconfig/sqlfun';

const Item = ({
    navigation, getList, objItem, bookid,
}) => (
    <View style={styles.container}>
        <TouchableOpacity
            style={{ padding: 10 }}
            onPress={() => {
                navigation.push('添加笔记',
                    {
                        bookid,
                        noteid: objItem.noteid,
                        getList,
                        isEditing: true,
                        title: objItem.title,
                    });
            }}
            onLongPress={() => Modal.operation([
                // {
                //     text: '删除',
                //     onPress: () => {
                //         delNote(parseInt(objItem.noteid, 10), parseInt(bookid, 10));
                //         getList();
                //     },
                //     style: { color: '#0F8DE9' },
                // },
                {
                    text: '删除',
                    onPress: () => {
                        moveToRecycle(parseInt(objItem.noteid, 10),
                            parseInt(bookid, 10), objItem.title);
                        getList();
                    },
                    style: { color: '#0F8DE9' },
                },
            ])}
        >
            <Text style={styles.title}>{objItem.title}</Text>
            <WhiteSpace />
            <WhiteSpace />
            <Text>{objItem.detail}</Text>
            <WhiteSpace />
            <Text>{moment(objItem.creattime).format('YY-MM-DD')}</Text>
        </TouchableOpacity>
    </View>
);
Item.defaultProps = {
    objItem: {},
    getList: () => {},
    bookid: null,
    title: '',
};
Item.propTypes = {
    objItem: PropTypes.objectOf(PropTypes.any),
    getList: PropTypes.func,
    bookid: PropTypes.string,
    title: PropTypes.string,

};
export default Item;
